package com.lottery.material.controller.portal.competition;

import com.lottery.material.common.JsonResult;
import com.lottery.material.entity.article.CompetitionInfo;
import com.lottery.material.service.portal.competition.CompetitionInfoService;
import com.lottery.material.vo.competition.CompetitionInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author:houjie
 * @Description: 赛事接口
 * @Date:Create in 2019/4/8 16:50
 */
@Api(value = "赛事相关接口", tags = { "赛事相关接口" })
@Controller
@RequestMapping("/portal/competition")
public class CompetitionController {

    @Autowired
    CompetitionInfoService competitionInfoService;

    @ApiOperation(value="获取赛事", notes="获取赛事")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "competitionType", value = "赛事类型（1：竞彩足球；2：竞彩篮球）", required = true, dataType = "String")
    })
    @PostMapping("/getCompetition")
    @ResponseBody
    public JsonResult getCompetition(@Valid CompetitionInfoVo competitionInfoVo){
        List<CompetitionInfo> competitionList = competitionInfoService.findAllByCompetitionTypeAndState(Integer.valueOf(competitionInfoVo.getCompetitionType()),1);
        return JsonResult.success("查询成功",competitionList);
    }
}
